import PureUserManageList from '../components/user-manage-list';
import * as UserAction from 'actions/user';
import { getFetchStatus } from 'actions/util';
import * as ReactRedux from 'react-redux';

const mapStateToProps = (state) => {
  return {
    isFetching: getFetchStatus(state, UserAction.search),
    users: state.searchUserList
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    onSearchSubmit(query) {
      return dispatch(UserAction.search(query));
    },
    onCreateUser(user){
      return dispatch(UserAction.create(user));
    },
    resetPassword(userId, password){
      return dispatch(UserAction.resetPassword(userId, password));
    },
    lockUser(user, query){
      return dispatch(UserAction.lockUser(user.id));
    },
    unlockUser(user, query){
      return dispatch(UserAction.unlockUser(user.id));
    }
  };
};

export default ReactRedux.connect(mapStateToProps, mapDispatchToProps)(PureUserManageList);
